﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SqlDataTypes
{
    public class SqlBinary : SqlDataType
    {
        private string name = "binary";
        private string sqlQuery;
        private const int MAXSIZE = 8000;
        private const int MINSIZE = 1;
        private int size;

        public SqlBinary()
        {
            size = 30;
            sqlQuery = GetSqlQuery();
        }

        public SqlBinary(int size)
        {
            Size = size;
            sqlQuery = GetSqlQuery();
        }

        private string GetSqlQuery()
        {
            return name + "(" + size.ToString() + ")";
        }

        private int Size
        {
            set
            {
                if (value > MAXSIZE)
                {
                    size = MAXSIZE;
                }
                else if (value < MINSIZE)
                {
                    size = MINSIZE;
                }
                else
                {
                    size = value;
                }
            }
        }

        public override string Name
        {
            get { return name; }
        }

        public override string SqlCommand
        {
            get { return sqlQuery; }
        }
    }
}
